package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.formListPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:formListMapp
 * Package:com.example.mapper
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/9/19 12:46
 * @Version 1.0
 */
@Mapper
public interface formListMapp {
    // 指定数据库，使用低代码正式数据库
    @DS("newMscLowCodeFormal")
    // 定义将接收到的数据分别放入到数据库的哪个字段
    @Insert("insert into ddm_form_list(" +
            "id, create_time, update_time, creator, " +
            "sys_update_user, sys_audit_user, sys_audit_time, " +
            "sys_deleted, number, name, " +
            "name_english, name_russian, version_number, " +
            "upload_person, upload_time, revise_time, " +
            "document_path, process_status) " +
            "VALUES (" +
            "#{id}, #{create_time}, #{update_time}, #{creator}, " +
            "#{sys_update_user}, #{sys_audit_user}, #{sys_audit_time}, " +
            "#{sys_deleted}, #{number}, #{name}, " +
            "#{name_english}, #{name_russian}, #{version_number}, " +
            "#{upload_person}, #{upload_time}, #{revise_time}, " +
            "#{document_path}, #{process_status})")
    // 声明insert方法不返回任何值
    void addFormSystemDocument(formListPojo pojo);

    @DS("newMscLowCodeFormal")
    //*代表所有字段
    @Select("select * from low_code_formal.ddm_form_list where sys_deleted=0 order by number")
    List<formListPojo> queryAll();

    @DS("newMscLowCodeFormal")
    @Update("update ddm_form_list " +
            "set " +
            "number = #{number}, name = #{name}, " +
            "name_english = #{name_english}, name_russian = #{name_russian}, " +
            "update_time = #{update_time}, revise_time = #{revise_time}, " +
            "document_path = #{document_path}, version_number = #{version_number}, " +
            "update_time =#{update_time}, sys_update_user = #{sys_update_user}, " +
            "sys_deleted = #{sys_deleted} " +
            "where id = #{id}")
    void updateFormDocument(formListPojo pojo);

    @Select("select * from low_code_formal.ddm_form_list where id = #{id}")
    formListPojo getDocumentById(String id);
}
